﻿using System.Linq.Expressions;

namespace WT.OpenIddict.Repository.Services;

public static class ExpressionExtensions
{
    public static Expression<Func<T, bool>> And<T>(
        this Expression<Func<T, bool>> left,
        Expression<Func<T, bool>> right)
    {
        var invokedRight = Expression.Invoke(right, left.Parameters);
        return Expression.Lambda<Func<T, bool>>(
            Expression.AndAlso(left.Body, invokedRight),
            left.Parameters);
    }
}